<?php
/**
 * Created by PhpStorm.
 * User: jack Wang
 * Date: 2021/10/29
 * Time: 11:12
 */

/**
 * Class Base_Model
 * @property Logs
 */
class Base_Model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    /*
     * 通用的简单检索
     */
    public function commonQuery($fields, $where, $table)
    {
        $query = $this->db->select($fields)->where($where)->get($table);
        return $query->num_rows() ? $query->result_array() : [];
    }

    /*
     * 通用的简单删除
     */
    public function commonDelete($table, $where)
    {
        $this->db->delete($table, $where);
        return $this->db->affected_rows() ? true : false;
    }

    /*
     * 通用的新增
     */
    public function commonInsert($table, $value)
    {
        $this->db->insert($table, $value);
        return $this->db->affected_rows() ? true : false;
    }

    /*
     * 通用的修改
     */
    public function commonUpdate($table, $value, $where)
    {
        $this->db->update($table, $value, $where);
        return $this->db->affected_rows() ? true : false;
    }
}